<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>写文章 - EasyBlog博客</title>
    <link rel="shortcut icon" th:href="@{/static/favicon.ico}"/>
    <link rel="bookmark" th:href="@{/static/favicon.ico}"/>
    <link rel="stylesheet" href="../../../static/css/easyblog.css" th:href="@{/static/css/easyblog.css}">
    <link rel="stylesheet" href="../../../static/lib/css/editormd.css" th:href="@{/static/lib/css/editormd.css}">
    <link rel="stylesheet" href="../../../static/css/semantic-specifc.css" th:href="@{/static/css/semantic-specifc.css}">
    <script src="../static/js/spop.js" th:src="@{/static/js/spop.js}"></script>
    <link rel="stylesheet" href="../static/css/spop.css" th:href="@{/static/css/spop.css}">
    <link rel="stylesheet" href="../static/css/loading/zeroModal.css" th:href="@{/static/css/loading/zeroModal.css}">
</head>
<body>

<!--编辑器-->
<div style="margin-top: 5px !important;">
    <form id="blog" action="#" th:if="${user!=null}" method="post" class="ui form">
        <!--用于编辑文章-->
        <input type="hidden" id="articleId" th:if="${article!=null}" th:value="${article.getArticleId()}">
        <div class="ui row fluid  stackable centered grid"
             style="margin-left: 0.5rem !important;margin-right: 0.5em !important;">
            <div class="left float  right aligned  two wide centered column">
                <div class="ui segment"
                     style="background: none !important;border: none !important;box-shadow: none !important;padding-left: 0 !important;padding-right: 0 !important;">
                    <a href="#" th:href="@{/manage/blog/}" class="ui right floated"
                       style="color: #8da6ce !important;font-size: 1.23rem !important;">
                        <svg xmlns="http://www.w3.org/2000/svg" width="89px"
                             height="17px" viewBox="0 0 89 17" version="1.1">
                            <g id="页面1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
                                <g id="MD编辑器优化-20190916" transform="translate(-24.000000, -24.000000)" fill="#6B6B6B">
                                    <g id="Group-4" transform="translate(21.000000, 24.000000)">
                                        <path d="M11.2719767,13.1315385 C11.4864972,13.3286154 11.6239413,13.6086154 11.6239413,13.9230769 C11.6239413,14.5175385 11.1410006,15 10.5459486,15 C10.2651315,15 10.0118033,14.8901538 9.81992058,14.7140769 L9.8172256,14.7167692 L3.34926962,8.79369231 L3.3519646,8.791 C3.13690507,8.59392308 3,8.31392308 3,8 C3,7.68553846 3.13690507,7.40553846 3.3519646,7.20846154 L3.34926962,7.20630769 L9.8172256,1.28323077 L9.81992058,1.28538462 C10.0118033,1.10984615 10.2651315,1 10.5459486,1 C11.1410006,1 11.6239413,1.48192308 11.6239413,2.07692308 C11.6239413,2.39084615 11.4864972,2.67138462 11.2719767,2.86792308 L11.2741327,2.87061538 L5.6734218,8 L11.2741327,13.1288462 L11.2719767,13.1315385 Z M21.152,3.336 L28.604,3.336 C28.118,2.382 27.524,1.482 26.804,0.636 L28.1,0.168 C28.784,1.032 29.396,2.094 29.972,3.336 L36.848,3.336 L36.848,4.632 L34.04,4.632 C33.158,7.476 31.826,9.87 30.062,11.778 C31.97,13.398 34.364,14.73 37.244,15.792 L36.542,16.872 C33.554,15.756 31.106,14.37 29.162,12.696 C27.11,14.586 24.554,15.972 21.494,16.854 L20.81,15.72 C23.834,14.91 26.318,13.632 28.262,11.868 C26.174,9.816 24.734,7.404 23.924,4.632 L21.152,4.632 L21.152,3.336 Z M25.202,4.632 C25.976,7.062 27.29,9.168 29.162,10.968 C30.764,9.222 31.934,7.116 32.69,4.632 L25.202,4.632 Z M46.37,12.066 L41.348,12.066 L41.348,6.594 L52.688,6.594 L52.688,12.066 L47.702,12.066 L47.702,13.326 L54.92,13.326 L54.92,14.478 L47.702,14.478 L47.702,16.728 L46.37,16.728 L46.37,14.478 L39.08,14.478 L39.08,13.326 L46.37,13.326 L46.37,12.066 Z M42.626,9.834 L42.626,10.986 L51.41,10.986 L51.41,9.834 L42.626,9.834 Z M51.41,8.826 L51.41,7.674 L42.626,7.674 L42.626,8.826 L51.41,8.826 Z M42.968,2.688 L40.25,2.688 L40.25,1.554 L46.208,1.554 C46.064,1.122 45.902,0.708 45.722,0.348 L47.108,0.132 C47.288,0.564 47.45,1.032 47.63,1.554 L53.75,1.554 L53.75,2.688 L51.086,2.688 L50.438,4.362 L54.686,4.362 L54.686,5.478 L39.332,5.478 L39.332,4.362 L43.634,4.362 L42.968,2.688 Z M44.948,4.362 L49.106,4.362 L49.736,2.688 L44.282,2.688 L44.948,4.362 Z M70.148,7.404 L70.148,10.932 L61.166,10.932 L61.166,12.174 L70.976,12.174 L70.976,16.8 L69.698,16.8 L69.698,16.044 L61.166,16.044 L61.166,16.782 L59.87,16.782 L59.87,7.404 L70.148,7.404 Z M61.166,14.892 L69.698,14.892 L69.698,13.218 L61.166,13.218 L61.166,14.892 Z M61.166,9.888 L68.888,9.888 L68.888,8.448 L61.166,8.448 L61.166,9.888 Z M72.632,5.226 L72.632,8.484 L71.372,8.484 L71.372,6.342 L58.628,6.342 L58.628,8.484 L57.368,8.484 L57.368,5.226 L64.496,5.226 C64.316,4.794 64.136,4.416 63.938,4.056 L65.198,3.84 L65.09,3.768 C65.954,2.688 66.566,1.518 66.962,0.222 L68.204,0.492 C68.078,0.87 67.952,1.23 67.808,1.59 L73.01,1.59 L73.01,2.724 L69.806,2.724 C70.184,3.228 70.49,3.696 70.706,4.128 L69.554,4.56 C69.23,3.912 68.852,3.3 68.42,2.724 L67.286,2.724 C66.962,3.336 66.584,3.912 66.188,4.452 L65.216,3.858 C65.414,4.272 65.612,4.722 65.792,5.226 L72.632,5.226 Z M59.528,2.724 C59.096,3.426 58.628,4.074 58.088,4.668 L56.954,3.948 C58.034,2.832 58.826,1.572 59.33,0.204 L60.572,0.474 C60.428,0.87 60.266,1.23 60.122,1.59 L64.946,1.59 L64.946,2.724 L61.922,2.724 C62.318,3.264 62.66,3.786 62.912,4.272 L61.724,4.722 C61.4,4.038 61.004,3.372 60.554,2.724 L59.528,2.724 Z M81.488,1.014 L90.29,1.014 L90.29,9.33 L86.546,9.33 L86.546,11.454 L90.596,11.454 L90.596,12.678 L86.546,12.678 L86.546,15.018 L91.262,15.018 L91.262,16.26 L80.426,16.26 L80.426,15.018 L85.25,15.018 L85.25,12.678 L81.182,12.678 L81.182,11.454 L85.25,11.454 L85.25,9.33 L81.488,9.33 L81.488,1.014 Z M89.048,8.178 L89.048,5.748 L86.546,5.748 L86.546,8.178 L89.048,8.178 Z M85.25,8.178 L85.25,5.748 L82.73,5.748 L82.73,8.178 L85.25,8.178 Z M82.73,4.614 L85.25,4.614 L85.25,2.166 L82.73,2.166 L82.73,4.614 Z M86.546,2.166 L86.546,4.614 L89.048,4.614 L89.048,2.166 L86.546,2.166 Z M75.134,6.972 L77.096,6.972 L77.096,2.706 L74.882,2.706 L74.882,1.482 L80.624,1.482 L80.624,2.706 L78.428,2.706 L78.428,6.972 L80.408,6.972 L80.408,8.214 L78.428,8.214 L78.428,12.3 C79.112,12.066 79.76,11.814 80.408,11.526 L80.408,12.786 C78.752,13.47 76.97,14.046 75.062,14.514 L74.738,13.272 C75.53,13.128 76.322,12.948 77.096,12.732 L77.096,8.214 L75.134,8.214 L75.134,6.972 Z" id="形状结合"></path>
                                    </g>
                                </g>
                            </g>
                        </svg>
                    </a>
                </div>
            </div>
            <div th:if="${article==null}" class="left float  left aligned ten wide  column"
                 style="margin-right: 0 !important;">
                <div class="field" style="margin-bottom: 0.5em !important;">
                    <div class="ui large  input ">
                        <input style="float: left" id="title" type="text" name="title" placeholder="文章标题">
                    </div>
                </div>
            </div>
            <div th:if="${article!=null}" class="left float  left aligned eleven wide  column"
                 style="margin-right: 0 !important;">
                <div class="field" style="margin-bottom: 0.5em !important;">
                    <div class="ui large  input ">
                        <input th:value="${article.getArticleTopic()}" id="title" type="text" name="title"
                               placeholder="文章标题">
                    </div>
                </div>
            </div>
            <div  class=" left float  center aligned two wide centered column"
                 style="padding-left: 0 !important;padding-right: 0 !important;max-width: 100px !important;">
                <button id="instanceSave" type="button" class="ui medium right floated basic red button" style="color:#ca0c16 !important;margin-left: 0 !important;">
                    保存草稿
                </button>
            </div>
            <div class="left float  center aligned two wide centered column"
                 style="padding-left: 0 !important;margin-right: 0 !important;padding-right: 0 !important;max-width: 100px !important;">
                <a id="go" rel="leanModal" name="signup" onclick="$(function() {
                  $('#signup-title').text('发布文章');
                });" href="#signup">
                    <button class="ui medium right floated red button"
                            style="color:#ffffff !important;margin-left: 0 !important;">
                        发布文章
                    </button>
                </a>
            </div>
        </div>
        <div class="field" style="margin-top: 1px !important;">
            <div id="md-content" style="z-index: 1 !important;">
                <textarea th:if="${article==null}" id="content" name="content" style="display: none"></textarea>
                <textarea th:if="${article!=null}" th:text="${article.getArticleContent()}" id="content" name="content"
                          style="display: none"></textarea>
            </div>
        </div>
    </form>
</div>

<!--弹出框-->
<div id="signup">
    <div id="signup-ct">
        <div id="signup-header">
            <h2 id="signup-title">发布文章</h2>
            <a class="modal_close" href="#"></a>
        </div>
        <div>
            <input type="hidden" name="articleUser" th:value="${userId}">
            <div class="ui doubling stackable grid container">
                <!--分类专栏-->
                <div class="row" style="margin-top: 15px !important;">
                    <div class="center aligned three wide column" style="padding-top: 0.5em !important;">
                        分类专栏
                    </div>
                    <div class="thirteen wide column" style="margin-top: 5px !important;padding-left: 0 !important;">
                        <div class="ui field">
                            <select id="types" name="maxCount" class="ui dropdown type">
                                <option value="-1" selected>请选择</option>
                                <option th:if="${article!=null}" th:each="category:${categories}"
                                        th:selected="${article.getArticleCategory()==category.getCategoryName()}"
                                        value="1" th:value="${category.getCategoryId()}">
                                    [[${category.getCategoryName()}]]
                                </option>
                                <option th:if="${article==null}" th:each="category:${categories}" value="1"
                                        th:value="${category.getCategoryId()}">
                                    [[${category.getCategoryName()}]]
                                </option>
                            </select>
                        </div>
                        <div class="ui fluid icon input">
                            <input id="add-input" type="text" placeholder="添加分类..."
                                   style="display: none !important;margin-top: 5px;max-width: 14em">
                            <div class="ui field" style="padding-top: 5px !important;padding-left: 3px !important;">
                                <div id="add-type-btn" class="ui tiny primary submit button">
                                    添加分类
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <!--文章类型-->
                <div class="row">
                    <div class="center aligned three wide column" style="padding-top: 0.5em !important;">
                        文章类型
                    </div>
                    <div class="thirteen wide column" style="padding-left: 0 !important;">
                        <div class="field">
                            <select id="article_type" name="minCount" class="ui dropdown">
                                <option value="-1">请选择</option>
                                <option th:if="${article!=null}" th:selected="${article.getArticleType()=='0'}"
                                        value="0">原创
                                </option>
                                <option th:if="${article==null}" value="0">原创</option>
                                <option th:if="${article!=null}" th:selected="${article.getArticleType()=='1'}"
                                        value="1">转载
                                </option>
                                <option th:if="${article==null}" value="1">转载</option>
                                <option th:if="${article!=null}" th:selected="${article.getArticleType()=='2'}"
                                        value="2">翻译
                                </option>
                                <option th:if="${article==null}" value="2">翻译</option>
                            </select>
                        </div>
                    </div>
                </div>

                <div class="row " style="margin-top: 15px !important;">
                    <div class="center aligned three wide column" style="padding-top: 0.5em !important;">
                        开启赞赏
                    </div>
                    <div class="thirteen wide column" style="margin-top: 5px !important;padding-left: 0 !important;">
                        <div class="ui field">
                            <select id="appreciate" class="ui dropdown tags">
                                <option value="-1" selected>请选择</option>
                                <option th:if="${article==null}" value="0">否</option>
                                <option th:if="${article==null}" value="1">是</option>
                                <option th:if="${article!=null}" th:selected="${article.getArticleAppreciate()=='0'}"
                                        value="0">否
                                </option>
                                <option th:if="${article!=null}" th:selected="${article.getArticleAppreciate()=='1'}"
                                        value="1">是
                                </option>
                            </select>
                        </div>
                    </div>
                </div>

                <!--发布形式-->
                <div class="row">
                    <div class="center aligned three wide column" style="padding-top: 0.5em !important;">
                        发布形式
                    </div>
                    <div class="thirteen wide column" style="padding-left: 0 !important;">
                        <div class="ui form">
                            <div class="inline fields">
                                <div class="field">
                                    <div class="ui radio checkbox">
                                        <input id="public" type="radio" name="frequency" th:if="${article!=null}">
                                        <input id="public" type="radio" name="frequency" th:if="${article==null}"
                                               checked>
                                        <label>公开</label>
                                    </div>
                                </div>
                                <div class="field">
                                    <div class="ui radio checkbox">
                                        <input id="private" type="radio" th:if="${article!=null}" name="frequency">
                                        <input id="private" type="radio" th:if="${article==null}" name="frequency">
                                        <label>私有</label>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="row" style="padding-top: 0 !important;padding-bottom: 0 !important;">
                    <div class="right aligned sixteen wide column" style="padding-top: 0.5em !important;">
                        <span style="color: rgb(202, 12, 22)">温馨提示：请勿发布涉及政治、广告、营销、翻墙、违反国家法律法规等内容</span>
                    </div>
                </div>
                <div class="right aligned row" style="padding-bottom: 5px !important;">
                    <div class="right aligned sixteen wide column" style="padding-top: 0.5em !important;">
                        <button id="cancel-btn" class="ui  floated button basic">取消</button>
                        <button th:if="${article==null}" id="draft-btn" class="ui  floated button basic blue ">保存草稿
                        </button>
                        <button id="publish-btn" class="ui  floated button basic red ">发布文章</button>
                    </div>
                </div>
                <div class="row" style="padding-bottom: 10px !important;"></div>
            </div>
        </div>
    </div>
</div>

</body>
<script src="https://cdn.jsdelivr.net/npm/jquery@3.2/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/semantic-ui/2.2.4/semantic.min.js"></script>
<script src="../../../static/lib/editormd.min.js" th:src="@{/static/lib/editormd.min.js}"></script>
<script src="../../../static/lib/editormd.amd.js" th:src="@{/static/lib/editormd.amd.min.js}"></script>
<script src="../../../static/js/easyblog.js" th:src="@{/static/js/easyblog.js}"></script>
<script src="../static/js/loading/mustache.js" th:src="@{/static/js/loading/mustache.js}"></script>
<script src="../static/js/loading/zeroModal.js" th:src="@{/static/js/loading/zeroModal.js}"></script>
<script type="text/javascript">
    $('#msg-btn').click(function () {
        $('.ui.modal').modal('hide');
    });
    $(document).ready(function () {
        publishArticle();
        saveDraft();
    });

</script>
<script type="text/javascript">
    //初始化Markdown编辑器
    var contentEditor;
    $(function () {
        contentEditor = editormd("md-content", {
            width: "100%",
            height: 660,
            syncScrolling: "single",
                placeholder: "Enjoy Markdown! Writing Now...",
            path: "[[${#request.getContextPath()}]]/static/lib/lib/",
            emoji: true,
            taskList: true,
            tocm: true, // Using [TOCM]
            tex: true, // 开启科学公式TeX语言支持，默认关闭
            flowChart: true, // 开启流程图支持，默认关闭
            sequenceDiagram: true, // 开启时序/序列图支持，默认关闭,
            searchReplace: true,
            imageFormats: ["jpg", "jpeg", "gif", "png", "bmp", "webp"],
            imageUpload: true,
            imageUploadURL: "[[${#request.getContextPath()}]]/upload/interface3",
            dialogLockScreen: false,   //设置弹出层对话框不锁屏，全局通用，默认为true
        });
    });
    $('.menu.toggle').click(function () {
        $('.m-item').toggleClass('m-mobile-hide');
    });

    $('.ui.dropdown').dropdown({
        on: 'hover'
    });
</script>
<!--文章发布信息框-->
<script type="text/javascript">
    $(function () {
        $('a[rel*=leanModal]').leanModal({top: 200, closeButton: ".modal_close"});
    });

    (function ($) {
        $.fn.extend({
            leanModal: function (options) {
                var defaults = {
                    top: 100,
                    overlay: 0.5,
                    closeButton: null
                };
                var overlay = $("<div id='lean_overlay'></div>");
                $("body").append(overlay);
                options = $.extend(defaults, options);
                return this.each(function () {
                    var o = options;
                    $(this).click(function (e) {
                        var modal_id = $(this).attr("href");
                        $("#lean_overlay").click(function () {
                            close_modal(modal_id)
                        });
                        $(o.closeButton).click(function () {
                            close_modal(modal_id)
                        });
                        var modal_height = $(modal_id).outerHeight();
                        var modal_width = $(modal_id).outerWidth();
                        $("#lean_overlay").css({
                            "display": "block",
                            opacity: 0
                        });
                        $("#lean_overlay").fadeTo(200, o.overlay);
                        $(modal_id).css({
                            "display": "block",
                            "position": "fixed",
                            "opacity": 0,
                            "z-index": 1000,
                            "left": 50 + "%",
                            "margin-left": -(modal_width / 2) + "px",
                            "top": o.top - 100 + "px"
                        });
                        $(modal_id).fadeTo(200, 1);
                        e.preventDefault()
                    })
                });

                function close_modal(modal_id) {
                    $("#lean_overlay").fadeOut(200);
                    $(modal_id).css({
                        "display": "none"
                    })
                }
            }
        })
    })(jQuery);
</script>
<script type="text/javascript">
    //控制分类栏
    $("#add-type-btn").click(function () {
        $("#add-input").show();
    });
    $("#add-input").blur(function () {
        $("#add-type-btn").click(function () {
            var str = $("#add-input").val();
            if (str !== "") {
                let options = $('#types').find("option");
                let flag = true;
                for (let i = 0; parseInt(i) < parseInt(options.length); i++) {
                    let channlVar = options.eq(i).text();   //option中的值
                    channlVar = channlVar.replace(/\s*/g, "");
                    //console.log(channlVar);
                    if (channlVar == str) {
                        showErrorMessage('您已经存在' + str + '分类,请不要重复添加！');
                        flag = false;
                        break;
                    }
                }
                if (flag) {
                    var select = document.getElementById("types");
                    var option = new Option();  //产生一个Option结点
                    var value = select.childElementCount;
                    option.text = str;
                    option.value = value;
                    $("#types").append(option);
                    $("#types").find("option[value='" + select.childElementCount + "']").attr("selected", true);
                }
                str = "";
            }
        });
    });

</script>
<script type="text/javascript" th:online="javascript">
    /**
     *弹出框按钮控制
     */
    //取消===>关闭弹框
    $('#cancel-btn').click(function () {
        $('#signup').css("display", "none");
    });

    /**
     * 提交文章草稿
     * @type {string}
     */
    /*let userId = "[[${user.getUserId()}]]";*/
    //记录文章保存的次数
    let savedCount=-1;
    $(document).ready(function () {
        $(document).keydown(function () {
            //当键盘按键按下的时候把修改标志置0
            savedCount=0;
        });
    });

    //保存为草稿
    function saveDraft() {
        $('#draft-btn,#instanceSave').click(function () {
            let articleId = localStorage.getItem("articleId");
            if ("undefined" === articleId || null == articleId) {
                articleId = -1;
            }
            let title = $('#title').val();
            let content = $('#content').val();
            let categoryName = $('#types').find("option:selected").text();
            let articleType = $('#article_type').val() == -1 ? 0 : $('#article_type').val();
            let appreciate = $('#appreciate').find("option:selected").val() == -1 ? 0 : $('#appreciate').find("option:selected").val();
            if (categoryName == "请选择") {
                categoryName = null;
            }
            if (title == null || title == "") {
                _alert1("请填写文章标题");
            } else if (content == null || content == "") {
                _alert1("写点内容再保存吧");
            } else {
                _loading(2);
                $.ajax({
                    url: "/manage/blog/saveAsDraft/",
                    method: "POST",
                    sync: true,
                    contentType: "application/json",
                    data: JSON.stringify({
                        articleId: articleId,
                        articleTopic: title,
                        articleCategory: categoryName,
                        articleType: articleType,
                        articleAppreciate: appreciate,
                        articleStatus: 2,
                        articleContent: content
                    }),
                    dataType: "json",     //服务器返回的数据类型
                    success: function (ajaxResult) {
                        _loadingClose();
                        //返回文章的id
                        articleId = ajaxResult.message;
                        if (ajaxResult.success) {
                            showSuccessMessage("已成功保存至草稿箱");
                            //把articleId存起来
                            localStorage.setItem('articleId', articleId);
                            //保存一次就将savedCount值1
                            savedCount=1;
                            window.location.href="/manage/blog/edit?articleId="+localStorage.getItem("articleId");
                        } else {
                            showErrorMessage(ajaxResult.message);
                        }
                    },
                    error: function (ajaxResult) {
                        _loadingClose();
                        showErrorMessage(ajaxResult.message);
                    }
                });
            }
        });
    }

    /**
     * 发布文章
     * @type {string}
     */
    function publishArticle() {
        $('#publish-btn').click(function () {
            let articleId = $('#articleId').val();
            if ("undefined" === articleId || null == articleId) {
                articleId = localStorage.getItem("articleId");
                if ("undefined" === articleId || null == articleId) {
                    articleId = -1;
                }
            }

            let title = $('#title').val();
            let content = $('#content').val();
            let categoryName = $('#types').find("option:selected").text();
            let articleType = $('#article_type').val();
            let appreciate = $('#appreciate').find("option:selected").val();
            let publicArticle = $('#public').is(":checked");
            let status = "0";
            if (!publicArticle) {
                status = "1";
            }
            if (title == null || title == "") {
                _alert1("请填写文章标题");
            } else if (content == null || content == "") {
                _alert1("写点内容再发布吧");
            } else if ("请选择" == categoryName) {
                _alert1("请选择文章分类");
            } else if ("-1" == articleType) {
                _alert1("请选择文章类型");
            } else {
                _loading(2);
                $.ajax({
                    url: "/manage/blog/saveArticle/",
                    method: "POST",
                    sync: true,
                    contentType: "application/json",
                    data: JSON.stringify({
                        articleId: articleId,
                        articleTopic: title,
                        articleCategory: categoryName,
                        articleType: articleType,
                        articleAppreciate: appreciate,
                        articleStatus: status,
                        articleContent: content
                    }),
                    dataType: "json",     //服务器返回的数据类型
                    success: function (ajaxResult) {
                        _loadingClose();
                        let articleId = ajaxResult.message;
                        if (ajaxResult.success) {
                            localStorage.removeItem("articleId");
                            savedCount=1;
                            //跳转到成功页面
                            window.location.href = "/manage/blog/success/" + articleId ;
                        } else {
                            showErrorMessage(ajaxResult.message);
                        }
                    },
                    error: function (ajaxResult) {
                        _loadingClose();
                        showErrorMessage(ajaxResult.message);
                    }
                });
            }
        });
    }
</script>
<!--未保存关闭或刷新页面时提示-->
<script type="text/javascript">
    $(window).bind('beforeunload', function () {
        if(parseInt(savedCount)===parseInt(0)) {
            return '您输入的内容尚未保存，确定离开此页面吗？';
        }
    });
</script>
</html>
